<template>
  <div class="app-container">
    <div class="title">
      <h2>费用报销单</h2>
      <el-button type="primary" plain @click="onSubmit">保存</el-button>
    </div>
    <el-form :model="form" ref="form" :rules="rules" label-width="95px" :inline="false" size="small">
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="部门" prop="val1">
            <el-input v-model="form.val1"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="单据编号" prop="val2">
            <el-input v-model="form.val2"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="创建日期" prop="val3">
            <el-date-picker v-model="form.val3" type="date" placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="项目编号" prop="val7">
            <el-input v-model="form.val7"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="项目名称" prop="val8">
            <el-input v-model="form.val8"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="事由及说明" prop="val4">
            <el-input type="textarea" resize="none" :autosize="{ minRows: 4, maxRows: 6 }"
              v-model="form.val4"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="报销金额" prop="val5">
            <el-input v-model="form.val5"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="项目支出" prop="val6">
            <el-select v-model="form.val6" placeholder="请选择">
              <el-option label="是" value="是" />
              <el-option label="否" value="否" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-tabs type="border">
      <el-tab-pane label="报销结算">
        <el-button style="margin: 0 10px 10px;" plain type="warning" size="small" round icon="el-icon-plus"
          @click="onAdd">
          添加</el-button>
        <el-table :data="tableData" border stripe height="400px">
          <el-table-column align="center" label="序号" type="index" />
          <el-table-column label="费用类型" min-width="160px">
            <template slot-scope="scope">
              <el-select v-model="scope.row.val1" placeholder="请选择">
                <el-option label="一,经营费用" value="一,经营费用">
                </el-option>
                <el-option label="二,其他费用" value="二,其他费用">
                </el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="列支项目" min-width="180px">
            <template slot-scope="scope">
              <el-select v-model="form.val2" placeholder="请选择">
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="年度可用预算" min-width="120px">
            <template slot-scope="scope">
              <el-input v-model="scope.row.val3"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="单次可用预算" min-width="120px">
            <template slot-scope="scope">
              <el-input v-model="scope.row.val4"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="报销金额" min-width="120px">
            <template slot-scope="scope">
              <el-input v-model="scope.row.val5"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="备注" min-width="160px">
            <template slot-scope="scope">
              <el-input v-model="scope.row.val6"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="公司科目" min-width="160px">
            <template slot-scope="scope">
              <el-input v-model="scope.row.val7"></el-input>
            </template>
          </el-table-column>
          <el-table-column label="项目科目" min-width="160px">
            <template slot-scope="scope">
              <el-input v-model="scope.row.val8"></el-input>
            </template>
          </el-table-column>
        </el-table>

      </el-tab-pane>
    </el-tabs>

  </div>
</template>

<script>
export default {
  data() {
    return {
      rules: {
        val4: [
          { required: true, message: '请输入事由及说明', trigger: 'blur' },
        ],
        val5: [
          { required: true, message: '请输入报销金额', trigger: 'blur' },
        ],
        val6: [
          { required: true, message: '请输入项目支出', trigger: 'blur' },
        ],

      },
      options: [
        { label: '业务招待', value: '业务招待' },
        { label: '差旅费', value: '差旅费' },
        { label: '车辆费', value: '车辆费' },
        { label: '包装费', value: '包装费' },
        { label: '快递费', value: '快递费' },
      ],
      form: {},
      tableData: [
        { val1: '一,经营费用', val2: '', val3: '', val4: '', val5: '', val6: '', }
      ]
    }
  },
  methods: {
    onSubmit() {

    },
    onAdd() {
      this.tableData.push({ val1: '', val2: '', val3: '', val4: '', val5: '', val6: '', })
    }
  }
}
</script>

<style lang="scss" scoped>
.app-container {
  position: relative;
  padding-top: 50px;
}

.el-select {
  width: 100%;
}

.title {
  background: #fff;
  height: 50px;
  position: fixed;
  top: 90px;
  z-index: 1;
  display: flex;
  justify-content: flex-start;
  align-items: center;

  h2 {
    margin: 0;
    margin-right: 20px;
  }
}
</style>